﻿using Abp.Application.Services;
using Abp.Authorization;
using Abp.Domain.Repositories;
using Neocean.Mpa.Authorization;
using Neocean.Mpa.MusicStore.Dto;

namespace Neocean.Mpa.MusicStore
{
    [AbpAuthorize(PermissionNames.Pages_Movies)]
    public class MovieAppService : AsyncCrudAppService<Movie, 
        MovieResult, 
        int, 
        MovieCriteria,
        MovieResult>, IMovieAppService //MpaAppServiceBase, 
    {
        private readonly IRepository<Movie, int> _movieRepository;

        public MovieAppService(IRepository<Movie, int> movieRepository) : base(movieRepository)
        {
            _movieRepository = movieRepository;
        }

        //public Task<MovieResult> Create(MovieResult input)
        //{
        //    throw new NotImplementedException();
        //}

        //public Task Delete(EntityDto<int> input)
        //{
        //    throw new NotImplementedException();
        //}

        //public Task<MovieResult> Get(EntityDto<int> input)
        //{
        //    throw new NotImplementedException();
        //}

        //public async Task<PagedResultDto<MovieResult>> GetAll(MovieCriteria input)
        //{
        //    //throw new NotImplementedException();
        //    var movies = await _movieRepository
        //        .GetAll()
        //        .WhereIf(input.ReleaseDateFrom.HasValue, t => t.ReleaseDate > input.ReleaseDateFrom.Value)
        //        .OrderByDescending(t => t.CreationTime).AsQueryable()
        //        .ToListAsync();

        //    return new PagedResultDto<MovieResult>(
                 
        //        ObjectMapper.Map<List<MovieResult>>(movies)
        //    );
        //}

        //public Task<MovieResult> Update(MovieResult input)
        //{
        //    throw new NotImplementedException();
        //}
        //public async Task<ListResultDto<MovieResult>> GetAll(MovieCriteria criteria)
        //{
        //    //throw new NotImplementedException();
        //    var movies = await _movieRepository
        //        .GetAll()
        //        .WhereIf(criteria.ReleaseDateFrom.HasValue, t => t.ReleaseDate > criteria.ReleaseDateFrom.Value)
        //        .OrderByDescending(t => t.CreationTime).AsQueryable()
        //        .ToListAsync();

        //    return new ListResultDto<MovieResult>(
        //        ObjectMapper.Map<List<MovieResult>>(movies)
        //    );
        //}
    }
}
